import { color } from "echarts"

export default {
  ech_index_1:{
    /**
     * 类型：折线图
     * 创建图表echarts option
     * @param yName y轴名称
     * @param legend y轴名称
     * @param grid 位置
		 * @param xdatas x轴数据
		 * @param series 图表数据
     */
    buildOption({yName, grid, legend, xdatas, series}){
      return {
        tooltip: {
          trigger: 'axis'
        },
        grid: grid,
        legend: legend,
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: xdatas
        },
        yAxis: {
          type: 'value',
          name: yName
        },
        series: series
      }
    },
    baseData: {
      line1: {
        color: ['#5392f8'],
        yName: '(万元）',
        legend: {show: false},
        showSymbol: true,
				grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
      },
      line2: {
        color: ['#11c7ec'],
        yName: '(万人）',
        legend: {show: false},
        showSymbol: true,
				grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
      },
      line3: {
        color: ['#11c7ec'],
        yName: '(家）',
        legend: {show: false},
        showSymbol: false,
				grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
      },
      line4: {
        color: ['#11c7ec'],
        yName: '(人）',
        legend: {show: false},
        showSymbol: true,
				grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
      },
      line5: {
        color: ['#00CBFF','#FDCC02','#00F7FF'],
        yName: '(万元）',
        legend: {
          x: '4%',
          top: '2%',
          data: ['企业产出', '企业支出', '企业营收']
        },
        showSymbol: false,
				grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
      },
    },
  /**
   * 获取option
   * @param xdatas x轴数据
   * @param data 数据
   * @param key baseData 里的key
   */
    getOption(xdatas, data, key){
      let series = [];
      data.forEach((item, index) => {
        series.push({
          name: item.name,
          type: 'line',
          showSymbol: this.baseData[key].showSymbol,
          stack: 'Total',
          lineStyle: {
            color: this.baseData[key].color[index]
          },
          data: item.list
        })
      })
      return this.buildOption(Object.assign(this.baseData[key],{xdatas, series}))
    }
  },
  ech_index_2:{
    /**
     * 类型：分组柱状图
     * 创建图表echarts option
     * @param color 颜色
     * @param yName y轴名称
     * @param grid 位置
		 * @param xdatas x轴数据
		 * @param data 图表数据
     */
    buildOption({yName, grid, legend, xdatas, series}){
      return {
        tooltip: {
          trigger: 'axis'
        },
        grid: grid,
        legend: legend,
        xAxis: {
          type: 'category',
          data: xdatas
        },
        yAxis: {
          type: 'value',
          name: yName
        },
        series: series
      }
    },
    baseData: {
      bar1: {
        yName: '(万元）',
        legend: {
          x: '4%',
          top: '2%',
          data: ['特色产业投资', '特色产业产出']
        },
				grid: {
          top: '18%',
          left: '10%',
          right: '10%',
          bottom: '5%',
          containLabel: true
        },
      },
      bar2: {
        yName: '(人）',
        legend: {show:false},
				grid: {
          top: '12%',
          left: '5%',
          right: '10%',
          bottom: '5%',
          containLabel: true
        },
      },
      bar3: {
        yName: '(亿元）',
        legend: {
          x: '4%',
          top: '2%',
          data: ['产出', '税收']
        },
				grid: {
          top: '18%',
          left: '10%',
          right: '10%',
          bottom: '5%',
          containLabel: true
        },
      },
    },
  /**
   * 获取option
   * @param xdatas x轴数据
   * @param data 数据
   * @param key baseData 里的key
   */
    getOption(xdatas, data, key){
      let series = [];
      data.forEach(item => {
        series.push({
          name: item.name,
          data: item.list,
          type: 'bar'
        })
      })
      return this.buildOption(Object.assign(this.baseData[key],{xdatas, series}))
    }
  },
  ech_index_3:{
    /**
     * 类型：南丁格尔图
     * 创建图表echarts option
     * @param color 颜色
     * @param yName y轴名称
     * @param grid 位置
		 * @param xdatas x轴数据
		 * @param data 图表数据
     */
    buildOption({radius, center, legend, datas}){
      return {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: legend,
        series: [
          {
            name: 'Radius Mode',
            type: 'pie',
            radius: radius,
            center: center,
            roseType: 'radius',
            itemStyle: {
              borderRadius: 5
            },
            emphasis: {
              label: {
                show: true
              }
            },
            data: datas
          }
        ]
      }
    },
    baseData: {
      bar1: {
        radius: [20, 140],
        center: ['50%', '50%'],
        legend: {show: false}
      }
    },
  /**
   * 获取option
   * @param xdatas x轴数据
   * @param data 数据
   * @param key baseData 里的key
   */
    getOption(datas, key){
      return this.buildOption(Object.assign(this.baseData[key],{datas}))
    }
  }
}
